home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / xampp-win32-1.6.5-installer.exe / phpMyAdmin / libraries / tbl_properties.inc.php < prev    next >
Encoding:
PHP Script  |  2007-12-20  |  29.3 KB  |  721 lines

  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4.  *
  5.  * @version $Id: tbl_properties.inc.php 10588 2007-09-02 19:23:59Z lem9 $
  6.  */
  7.  
  8. /**
  9.  * Check parameters
  10.  */
  11. require_once './libraries/common.inc.php';
  12. PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
  13.  
  14.  
  15. // Get available character sets and storage engines
  16. require_once './libraries/mysql_charsets.lib.php';
  17. require_once './libraries/StorageEngine.class.php';
  18.  
  19. if (is_int($cfg['DefaultPropDisplay'])) {
  20.     if ($num_fields <= $cfg['DefaultPropDisplay']) {
  21.         $display_type = 'vertical';
  22.     } else {
  23.         $display_type = 'horizontal';
  24.     }
  25. } else {
  26.     $display_type = $cfg['DefaultPropDisplay'];
  27. }
  28.  
  29. if ($cfg['CtrlArrowsMoving']) {
  30.     ?>
  31. <script src="./js/keyhandler.js" type="text/javascript"></script>
  32. <script type="text/javascript">
  33. // <![CDATA[
  34. var switch_movement = <?php echo $display_type == 'horizontal' ? '0' : '1'; ?>;
  35. document.onkeydown = onKeyDownArrowsHandler;
  36. // ]]>
  37. </script>
  38.     <?php
  39. }
  40. // here, the div_x_7 represents a div id which contains
  41. // the default CURRENT TIMESTAMP checkbox and label
  42. // and, field_x_7a represents the checkbox itself
  43.  
  44. if (PMA_MYSQL_INT_VERSION >= 40102) {
  45.     ?>
  46. <script type="text/javascript">
  47. // <![CDATA[
  48. function display_field_options(field_type, i) {
  49.     if (field_type == 'TIMESTAMP') {
  50.         getElement('div_' + i + '_7').style.display = 'block';
  51.     } else {
  52.         getElement('div_' + i + '_7').style.display = 'none';
  53.         getElement('field_' + i + '_7a').checked = false;
  54.     }
  55.     return true;
  56. }
  57. // ]]>
  58. </script>
  59. <?php } ?>
  60.  
  61. <form method="post" action="<?php echo $action; ?>">
  62. <?php
  63. echo PMA_generate_common_hidden_inputs($db, $table);
  64. if ($action == 'tbl_create.php') {
  65.     ?>
  66.     <input type="hidden" name="reload" value="1" />
  67.     <?php
  68. } elseif ($action == 'tbl_addfield.php') {
  69.     ?>
  70.     <input type="hidden" name="field_where" value="<?php echo $field_where; ?>" />
  71.     <input type="hidden" name="after_field" value="<?php echo $after_field; ?>" />
  72.     <?php
  73. }
  74.  
  75. if (isset($num_fields)) {
  76.     ?>
  77.     <input type="hidden" name="orig_num_fields" value="<?php echo $num_fields; ?>" />
  78.     <?php
  79. }
  80.  
  81. if (isset($field_where)) {
  82.     ?>
  83.     <input type="hidden" name="orig_field_where" value="<?php echo $field_where; ?>" />
  84.     <?php
  85. }
  86.  
  87. if (isset($after_field)) {
  88.     ?>
  89.     <input type="hidden" name="orig_after_field" value="<?php echo $after_field; ?>" />
  90.     <?php
  91. }
  92.  
  93. if (isset($selected) && is_array($selected)) {
  94.     foreach ($selected AS $o_fld_nr => $o_fld_val) {
  95.         ?>
  96.     <input type="hidden" name="selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
  97.         <?php
  98.         if (!isset($true_selected)) {
  99.             ?>
  100.     <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
  101.             <?php
  102.         }
  103.  
  104.     }
  105.  
  106.     if (isset($true_selected) && is_array($true_selected)) {
  107.         foreach ($true_selected AS $o_fld_nr => $o_fld_val) {
  108.             ?>
  109.         <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
  110.             <?php
  111.         }
  112.     }
  113.  
  114. } elseif (isset($field)) {
  115.     ?>
  116.     <input type="hidden" name="orig_field" value="<?php echo urlencode($field); ?>" />
  117.     <input type="hidden" name="true_selected[] value="<?php echo (isset($orig_field) ? $orig_field : urlencode($field)); ?>" />
  118.     <?php
  119. }
  120.  
  121. $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
  122.  
  123. $header_cells = array();
  124. $content_cells = array();
  125.  
  126. $header_cells[] = $strField;
  127. $header_cells[] = $strType . ($GLOBALS['cfg']['ReplaceHelpImg'] ? PMA_showMySQLDocu('SQL-Syntax', 'data-types') : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'data-types') . '</span>');
  128. $header_cells[] = $strLengthSet . '<sup>1</sup>';
  129. if (PMA_MYSQL_INT_VERSION >= 40100) {
  130.     $header_cells[] = $strCollation;
  131. }
  132. $header_cells[] = $strAttr;
  133. $header_cells[] = $strNull;
  134. $header_cells[] = $strDefault . '<sup>2</sup>';
  135. $header_cells[] = $strExtra;
  136.  
  137.  
  138.  
  139. // lem9: We could remove this 'if' and let the key information be shown and
  140. // editable. However, for this to work, tbl_alter must be modified to use the
  141. // key fields, as tbl_addfield does.
  142.  
  143. if (!$is_backup) {
  144.     $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_primary.png" width="16" height="16" alt="' . $strPrimary . '" title="' . $strPrimary . '" />' : $strPrimary;
  145.     $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_index.png" width="16" height="16" alt="' . $strIndex . '" title="' . $strIndex . '" />' : $strIndex;
  146.     $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_unique.png" width="16" height="16" alt="' . $strUnique . '" title="' . $strUnique . '" />' : $strUnique;
  147.     $header_cells[] = '---';
  148.     $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_ftext.png" width="16" height="16" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' : $strIdxFulltext;
  149. }
  150.  
  151. require_once './libraries/relation.lib.php';
  152. require_once './libraries/transformations.lib.php';
  153. $cfgRelation = PMA_getRelationsParam();
  154.  
  155. $comments_map = array();
  156. $mime_map = array();
  157. $available_mime = array();
  158.  
  159. if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
  160.     $comments_map = PMA_getComments($db, $table);
  161.     $header_cells[] = $strComments;
  162.  
  163.     if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
  164.         $mime_map = PMA_getMIME($db, $table);
  165.         $available_mime = PMA_getAvailableMIMEtypes();
  166.  
  167.         $header_cells[] = $strMIME_MIMEtype;
  168.         $header_cells[] = $strMIME_transformation;
  169.         $header_cells[] = $strMIME_transformation_options . '<sup>3</sup>';
  170.     }
  171. }
  172.  
  173. // garvin: workaround for field_fulltext, because its submitted indizes contain
  174. //         the index as a value, not a key. Inserted here for easier maintaineance
  175. //         and less code to change in existing files.
  176. if (isset($field_fulltext) && is_array($field_fulltext)) {
  177.     foreach ($field_fulltext AS $fulltext_nr => $fulltext_indexkey) {
  178.         $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
  179.     }
  180. }
  181.  
  182. for ($i = 0 ; $i <= $num_fields; $i++) {
  183.     $submit_null = FALSE;
  184.     if (isset($regenerate) && $regenerate == TRUE) {
  185.         // An error happened with previous inputs, so we will restore the data
  186.         // to embed it once again in this form.
  187.  
  188.         $row['Field']     = (isset($field_name) && isset($field_name[$i]) ? $field_name[$i] : FALSE);
  189.         $row['Type']      = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE);
  190.         if (PMA_MYSQL_INT_VERSION >= 40100) {
  191.             $row['Collation']      = (isset($field_collation) && isset($field_collation[$i]) ? $field_collation[$i] : '');
  192.         }
  193.         $row['Null']      = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : '');
  194.         if (isset($field_type[$i]) && $row['Null'] == '') {
  195.             $submit_null = TRUE;
  196.         }
  197.  
  198.         if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
  199.             $row['Key'] = 'PRI';
  200.         } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
  201.             $row['Key'] = 'MUL';
  202.         } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
  203.             $row['Key'] = 'UNI';
  204.         } else {
  205.             $row['Key'] = '';
  206.         }
  207.  
  208.         $row['Default']   = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE);
  209.         $row['Extra']     = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
  210.         $row['Comment']   = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
  211.  
  212.         $submit_length    = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE);
  213.         $submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
  214.  
  215.         $submit_default_current_timestamp = (isset($field_default_current_timestamp) && isset($field_default_current_timestamp[$i]) ? TRUE : FALSE);
  216.  
  217.         if (isset($field_comments) && isset($field_comments[$i])) {
  218.             $comments_map[$row['Field']] = $field_comments[$i];
  219.         }
  220.  
  221.         if (isset($field_mimetype) && isset($field_mimetype[$i])) {
  222.             $mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
  223.         }
  224.  
  225.         if (isset($field_transformation) && isset($field_transformation[$i])) {
  226.             $mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
  227.         }
  228.  
  229.         if (isset($field_transformation_options) && isset($field_transformation_options[$i])) {
  230.             $mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
  231.         }
  232.  
  233.     } elseif (isset($fields_meta) && isset($fields_meta[$i])) {
  234.         $row = $fields_meta[$i];
  235.     }
  236.  
  237.     // Cell index: If certain fields get left out, the counter shouldn't chage.
  238.     $ci = 0;
  239.     // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
  240.     // has to be incremented ($ci_offset++)
  241.     $ci_offset = -1;
  242.  
  243.     if ($is_backup) {
  244.         $backup_field = (isset($true_selected) && isset($true_selected[$i]) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
  245.         $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_orig[]" value="' . $backup_field . '" />' . "\n";
  246.     } else {
  247.         $content_cells[$i][$ci] = '';
  248.     }
  249.  
  250.     $content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_name[]" size="10" maxlength="64" value="' . (isset($row) && isset($row['Field']) ? str_replace('"', '"', $row['Field']) : '') . '" class="textfield" title="' . $strField . '" />';
  251.     $ci++;
  252.     $content_cells[$i][$ci] = '<select name="field_type[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '" ';
  253.     if (PMA_MYSQL_INT_VERSION >= 40102) {
  254.         $content_cells[$i][$ci] .= 'onchange="display_field_options(this.options[this.selectedIndex].value,' . $i .')" ';
  255.     }
  256.     $content_cells[$i][$ci] .= '>' . "\n";
  257.  
  258.     if (empty($row['Type'])) {
  259.         $row['Type'] = '';
  260.         $type        = '';
  261.     } else {
  262.         $type        = $row['Type'];
  263.     }
  264.     // set or enum types: slashes single quotes inside options
  265.     if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
  266.         $type   = $tmp[1];
  267.         $length = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
  268.     } else {
  269.         // strip the "BINARY" attribute, except if we find "BINARY(" because
  270.         // this would be a BINARY or VARBINARY field type
  271.         $type   = preg_replace('@BINARY([^\(])@i', '', $type);
  272.         $type   = preg_replace('@ZEROFILL@i', '', $type);
  273.         $type   = preg_replace('@UNSIGNED@i', '', $type);
  274.  
  275.         if (strpos($type, '(')) {
  276.             $length = chop(substr($type, (strpos($type, '(') + 1), (strpos($type, ')') - strpos($type, '(') - 1)));
  277.             $type = chop(substr($type, 0, strpos($type, '(')));
  278.         } else {
  279.             $length = '';
  280.         }
  281.     } // end if else
  282.  
  283.     // some types, for example longtext, are reported as
  284.     // "longtext character set latin7" when their charset and / or collation
  285.     // differs from the ones of the corresponding database.
  286.     if (PMA_MYSQL_INT_VERSION >= 40100) {
  287.         $tmp = strpos($type, 'character set');
  288.         if ($tmp) {
  289.             $type = substr($type, 0, $tmp-1);
  290.         }
  291.     }
  292.  
  293.     if (isset($submit_length) && $submit_length != FALSE) {
  294.         $length = $submit_length;
  295.     }
  296.  
  297.     // rtrim the type, for cases like "float unsigned"
  298.     $type = rtrim($type);
  299.     $type_upper = strtoupper($type);
  300.  
  301.     $cnt_column_types = count($cfg['ColumnTypes']);
  302.     for ($j = 0; $j < $cnt_column_types; $j++) {
  303.         $content_cells[$i][$ci] .= '                <option value="'. $cfg['ColumnTypes'][$j] . '"';
  304.         if ($type_upper == strtoupper($cfg['ColumnTypes'][$j])) {
  305.             $content_cells[$i][$ci] .= ' selected="selected"';
  306.         }
  307.         $content_cells[$i][$ci] .= '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
  308.     } // end for
  309.  
  310.     $content_cells[$i][$ci] .= '    </select>';
  311.     $ci++;
  312.  
  313.     if ($is_backup) {
  314.         $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_length_orig[]" value="' . urlencode($length) . '" />';
  315.     } else {
  316.         $content_cells[$i][$ci] = '';
  317.     }
  318.  
  319.     if (preg_match('@^(set|enum)$@i', $type)) {
  320.         $binary           = 0;
  321.         $unsigned         = 0;
  322.         $zerofill         = 0;
  323.         $length_to_display = htmlspecialchars($length);
  324.     } else {
  325.         $length_to_display = $length;
  326.         if (!preg_match('@BINARY[\(]@i', $row['Type']) && PMA_MYSQL_INT_VERSION < 40100) {
  327.             $binary           = stristr($row['Type'], 'binary');
  328.         } else {
  329.             $binary           = FALSE;
  330.         }
  331.         $unsigned         = stristr($row['Type'], 'unsigned');
  332.         $zerofill         = stristr($row['Type'], 'zerofill');
  333.     }
  334.  
  335.     $content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_length[]" size="8" value="' . str_replace('"', '"', $length_to_display) . '" class="textfield" />' . "\n";
  336.     $ci++;
  337.  
  338.     if (PMA_MYSQL_INT_VERSION >= 40100) {
  339.         $tmp_collation          = empty($row['Collation']) ? null : $row['Collation'];
  340.         $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[]', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE);
  341.         unset($tmp_collation);
  342.         $ci++;
  343.     }
  344.  
  345.     $content_cells[$i][$ci] = '<select style="font-size: 70%;" name="field_attribute[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">' . "\n";
  346.  
  347.     $attribute     = '';
  348.     if ($binary) {
  349.         $attribute = 'BINARY';
  350.     }
  351.     if ($unsigned) {
  352.         $attribute = 'UNSIGNED';
  353.     }
  354.     if ($zerofill) {
  355.         $attribute = 'UNSIGNED ZEROFILL';
  356.     }
  357.  
  358.     if (isset($submit_attribute) && $submit_attribute != FALSE) {
  359.         $attribute = $submit_attribute;
  360.     }
  361.  
  362.     // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
  363.     // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
  364.     // the latter.
  365.     if (isset($row['Field'])
  366.     && isset($analyzed_sql[0])
  367.     && isset($analyzed_sql[0]['create_table_fields'])
  368.     && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
  369.     && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP'
  370.     && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
  371.         $row['Null'] = '';
  372.     }
  373.  
  374.     // MySQL 4.1.2+ TIMESTAMP options
  375.     // (if on_update_current_timestamp is set, then it's TRUE)
  376.     if (isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
  377.         $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
  378.     }
  379.     if ((isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
  380.      || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)) {
  381.         $default_current_timestamp = TRUE;
  382.     } else {
  383.         $default_current_timestamp = FALSE;
  384.     }
  385.  
  386.     // Dynamically add ON UPDATE CURRENT_TIMESTAMP to the possible attributes
  387.     if (PMA_MYSQL_INT_VERSION >= 40102 && !in_array('ON UPDATE CURRENT_TIMESTAMP', $cfg['AttributeTypes'])) {
  388.         $cfg['AttributeTypes'][] = 'ON UPDATE CURRENT_TIMESTAMP';
  389.     }
  390.  
  391.  
  392.     $cnt_attribute_types = count($cfg['AttributeTypes']);
  393.     for ($j = 0;$j < $cnt_attribute_types; $j++) {
  394.         if (PMA_MYSQL_INT_VERSION >= 40100 && $cfg['AttributeTypes'][$j] == 'BINARY') {
  395.             continue;
  396.         }
  397.         $content_cells[$i][$ci] .= '                <option value="'. $cfg['AttributeTypes'][$j] . '"';
  398.         if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
  399.             $content_cells[$i][$ci] .= ' selected="selected"';
  400.         }
  401.         $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
  402.     }
  403.  
  404.     $content_cells[$i][$ci] .= '</select>';
  405.     $ci++;
  406.  
  407.     $content_cells[$i][$ci] = '<select name="field_null[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
  408.  
  409.     if ((!isset($row) || empty($row['Null']) || $row['Null'] == 'NO' || $row['Null'] == 'NOT NULL') && $submit_null == FALSE) {
  410.         $content_cells[$i][$ci] .= "\n";
  411.         $content_cells[$i][$ci] .= '    <option value="NOT NULL" selected="selected" >not null</option>' . "\n";
  412.         $content_cells[$i][$ci] .= '    <option value="">null</option>' . "\n";
  413.     } else {
  414.         $content_cells[$i][$ci] .= "\n";
  415.         $content_cells[$i][$ci] .= '    <option value="" selected="selected" >null</option>' . "\n";
  416.         $content_cells[$i][$ci] .= '    <option value="NOT NULL">not null</option>' . "\n";
  417.     }
  418.  
  419.     $content_cells[$i][$ci] .= "\n" . '</select>';
  420.     $ci++;
  421.  
  422.     if (isset($row)
  423.       && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
  424.         $row['Default'] = 'NULL';
  425.     }
  426.  
  427.     if ($is_backup) {
  428.         $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_default_orig[]" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
  429.     } else {
  430.         $content_cells[$i][$ci] = "\n";
  431.     }
  432.  
  433.     // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
  434.     if (PMA_MYSQL_INT_VERSION >= 40102
  435.         && $type_upper == 'TIMESTAMP'
  436.         && $default_current_timestamp
  437.         && isset($row)
  438.         && isset($row['Default'])) {
  439.         $row['Default'] = '';
  440.     }
  441.  
  442.     $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_default[]" size="12" value="' . (isset($row) && isset($row['Default']) ? str_replace('"', '"', $row['Default']) : '') . '" class="textfield" />';
  443.     if (PMA_MYSQL_INT_VERSION >= 40102) {
  444.         if ($type_upper == 'TIMESTAMP') {
  445.             $tmp_display_type = 'block';
  446.         } else {
  447.             $tmp_display_type = 'none';
  448.             $default_current_timestamp = FALSE;
  449.         }
  450.         $content_cells[$i][$ci] .= '<br /><div id="div_' . $i . '_' . ($ci - $ci_offset) . '" style="white-space: nowrap; display: ' . $tmp_display_type . '"><input id="field_' . $i . '_' . ($ci - $ci_offset) . 'a" type="checkbox" name="field_default_current_timestamp[' . $i . ']"';
  451.         if ($default_current_timestamp) {
  452.             $content_cells[$i][$ci] .= ' checked="checked" ';
  453.         }
  454.         $content_cells[$i][$ci] .= ' /><label for="field_' . $i . '_' . ($ci - $ci_offset) . 'a" style="font-size: 70%;">CURRENT_TIMESTAMP</label></div>';
  455.     }
  456.     $ci++;
  457.  
  458.     $content_cells[$i][$ci] = '<select name="field_extra[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
  459.  
  460.     if (!isset($row) || empty($row['Extra'])) {
  461.         $content_cells[$i][$ci] .= "\n";
  462.         $content_cells[$i][$ci] .= '<option value=""> </option>' . "\n";
  463.         $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
  464.     } else {
  465.         $content_cells[$i][$ci] .= "\n";
  466.         $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
  467.         $content_cells[$i][$ci] .= '<option value=""> </option>' . "\n";
  468.     }
  469.  
  470.     $content_cells[$i][$ci] .= "\n" . '</select>';
  471.     $ci++;
  472.  
  473.  
  474.     // lem9: See my other comment about removing this 'if'.
  475.     if (!$is_backup) {
  476.         if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
  477.             $checked_primary = ' checked="checked"';
  478.         } else {
  479.             $checked_primary = '';
  480.         }
  481.         if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
  482.             $checked_index   = ' checked="checked"';
  483.         } else {
  484.             $checked_index   = '';
  485.         }
  486.         if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
  487.             $checked_unique   = ' checked="checked"';
  488.         } else {
  489.             $checked_unique   = '';
  490.         }
  491.         if (empty($checked_primary)
  492.             && empty($checked_index)
  493.             && empty($checked_unique)) {
  494.             $checked_none = ' checked="checked"';
  495.         } else {
  496.             $checked_none = '';
  497.         }
  498.  
  499.         if ((isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
  500.             $checked_fulltext = ' checked="checked"';
  501.         } else {
  502.             $checked_fulltext = '';
  503.         }
  504.  
  505.         $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="primary_' . $i . '"' . $checked_primary . ' title="' . $strPrimary . '" />';
  506.         $ci++;
  507.  
  508.         $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="index_' . $i . '"' .  $checked_index . ' title="' . $strIndex . '" />';
  509.         $ci++;
  510.  
  511.         $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="unique_' . $i . '"' .  $checked_unique . ' title="' . $strUnique . '" />';
  512.         $ci++;
  513.  
  514.         $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="none_' . $i . '"' .  $checked_none . ' title="---" />';
  515.         $ci++;
  516.  
  517.         $content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[]" value="' . $i . '"' . $checked_fulltext . ' title="' . $strIdxFulltext . '" />';
  518.         $ci++;
  519.     } // end if ($action ==...)
  520.  
  521.     // garvin: comments
  522.     if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
  523.         $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_comments[]" size="12" value="' . (isset($row) && isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ?  htmlspecialchars($comments_map[$row['Field']]) : '') . '" class="textfield" />';
  524.         $ci++;
  525.     }
  526.  
  527.     // garvin: MIME-types
  528.     if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
  529.         $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[]">' . "\n";
  530.         $content_cells[$i][$ci] .= '    <option value=""> </option>' . "\n";
  531.  
  532.         if (is_array($available_mime['mimetype'])) {
  533.             foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
  534.                 $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
  535.                 $content_cells[$i][$ci] .= '    <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
  536.             }
  537.         }
  538.  
  539.         $content_cells[$i][$ci] .= '</select>';
  540.         $ci++;
  541.  
  542.         $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[]">' . "\n";
  543.         $content_cells[$i][$ci] .= '    <option value="" title="' . $strNone . '"></option>' . "\n";
  544.         if (is_array($available_mime['transformation'])) {
  545.             foreach ($available_mime['transformation'] AS $mimekey => $transform) {
  546.                 $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation']) && (preg_match('@' . preg_quote($available_mime['transformation_file'][$mimekey]) . '3?@i', $mime_map[$row['Field']]['transformation'])) ? 'selected ' : '');
  547.                 $tooltip = 'strTransformation_' . strtolower(preg_replace('@(\.inc\.php3?)$@', '', $available_mime['transformation_file'][$mimekey]));
  548.                 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
  549.                 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>' . "\n";
  550.             }
  551.         }
  552.  
  553.         $content_cells[$i][$ci] .= '</select>';
  554.         $ci++;
  555.  
  556.         $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_transformation_options[]" size="16" value="' . (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ?  htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '" class="textfield" />';
  557.         //$ci++;
  558.     }
  559. } // end for
  560.  
  561. if (is_array($content_cells) && is_array($header_cells)) {
  562.     // last row is for javascript insert
  563.     $empty_row = array_pop($content_cells);
  564.  
  565.     echo '<table id="table_columns">';
  566.     if ($display_type == 'horizontal') {
  567.         ?>
  568. <tr>
  569.         <?php foreach ($header_cells as $header_val) { ?>
  570.     <th><?php echo $header_val; ?></th>
  571.         <?php } ?>
  572. </tr>
  573.         <?php
  574.  
  575.         $odd_row = true;
  576.         foreach ($content_cells as $content_row) {
  577.             echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
  578.             $odd_row = ! $odd_row;
  579.  
  580.             if (is_array($content_row)) {
  581.                 foreach ($content_row as $content_row_val) {
  582.                     ?>
  583.     <td align="center"><?php echo $content_row_val; ?></td>
  584.                     <?php
  585.                 }
  586.             }
  587.             echo '</tr>';
  588.         }
  589.     } else {
  590.         $i = 0;
  591.         $odd_row = true;
  592.         foreach ($header_cells as $header_val) {
  593.             echo '<tr class="' . ($odd_row ? 'odd' : 'even') . ' noclick">';
  594.             $odd_row = ! $odd_row;
  595.             ?>
  596.     <th><?php echo $header_val; ?></th>
  597.             <?php
  598.             foreach ($content_cells as $content_cell) {
  599.                 if (isset($content_cell[$i]) && $content_cell[$i] != '') {
  600.                     ?>
  601.     <td><?php echo $content_cell[$i]; ?></td>
  602.                     <?php
  603.                 }
  604.             }
  605.             echo '</tr>';
  606.             $i++;
  607.         }
  608.     }
  609.     ?>
  610. </table>
  611. <br />
  612.     <?php
  613. }
  614.  
  615. /**
  616.  * needs to be finished
  617.  *
  618.  *
  619. if ($display_type == 'horizontal') {
  620.     $new_field = '';
  621.     foreach ($empty_row as $content_row_val) {
  622.         $new_field .= '<td align="center">' . $content_row_val . '</td>';
  623.     }
  624.     ?>
  625. <script type="text/javascript">
  626. // <![CDATA[
  627. var odd_row = <?php echo $odd_row; ?>;
  628.  
  629. function addField() {
  630.     var new_fields = document.getElementById('added_fields').value;
  631.     var new_field_container = document.getElementById('table_columns');
  632.     var new_field = '<?php echo preg_replace('∩┐╜\s+∩┐╜', ' ', preg_replace('∩┐╜\'∩┐╜', '\\\'', $new_field)); ?>';
  633.     var i = 0;
  634.     for (i = 0; i < new_fields; i++) {
  635.         if (odd_row) {
  636.             new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
  637.         } else {
  638.             new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
  639.         }
  640.         odd_row = ! odd_row;
  641.     }
  642.  
  643.     return true;
  644. }
  645. // ]]>
  646. </script>
  647.     <?php
  648. }
  649.  */
  650.  
  651. if ($action == 'tbl_create.php') {
  652.     ?>
  653.     <table>
  654.     <tr valign="top">
  655.         <th><?php echo $strTableComments; ?>: </th>
  656.         <td width="25"> </td>
  657.     <th><?php echo $strStorageEngine; ?>: <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
  658.         </th>
  659.     <?php
  660.     if (PMA_MYSQL_INT_VERSION >= 40100) {
  661.         echo '        <td width="25"> </td>' . "\n"
  662.            . '        <th>' . $strCollation . ': </th>' . "\n";
  663.     }
  664.     ?>
  665.     </tr>
  666.     <tr><td><input type="text" name="comment" size="40" maxlength="80"
  667.                 value="<?php echo (isset($comment) ? $comment : ''); ?>"
  668.                 class="textfield" />
  669.         </td>
  670.         <td width="25"> </td>
  671.         <td>
  672. <?php echo PMA_StorageEngine::getHtmlSelect('tbl_type', null, (isset($GLOBALS['tbl_type']) ? $GLOBALS['tbl_type'] : null)); ?>
  673.         </td>
  674.         <?php
  675.         if (PMA_MYSQL_INT_VERSION >= 40100) {
  676.             echo '        <td width="25"> </td>' . "\n"
  677.                . '        <td>' . "\n"
  678.                . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, (isset($tbl_collation) ? $tbl_collation : null), FALSE, 3)
  679.                . '        </td>' . "\n";
  680.         }
  681.     ?>
  682.     </tr>
  683.     </table>
  684.     <br />
  685.     <?php
  686. } // end if ($action == 'tbl_create.php')
  687. ?>
  688.  
  689. <fieldset class="tblFooters">
  690.     <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" onclick="return checkTableEditForm(this.form, <?php echo $num_fields; ?>)" />
  691. <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
  692.     <?php echo $GLOBALS['strOr']; ?>
  693.     <?php echo sprintf($strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />'); ?>
  694.     <input type="submit" name="submit_num_fields"
  695.         value="<?php echo $GLOBALS['strGo']; ?>"
  696. <?php /*        onclick="if (addField()) return false;" */ ?>
  697.         onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
  698.         />
  699. <?php } ?>
  700. </fieldset>
  701.  
  702. </form>
  703.  
  704. <div class="notice">
  705.     <p> <a name="footnoote_setenumval"><sup>1</sup></a> <?php echo $strSetEnumVal; ?></p>
  706.     <p> <a name="footnoote_defaultvalue"><sup>2</sup></a> <?php echo $strDefaultValueHelp; ?></p>
  707. <?php
  708. if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
  709.     echo '<p> <a name="footnoote_mime"><sup>3</sup></a> ' . $strMIME_transformation_options_note . '</p>';
  710.     echo '<p> ';
  711.     printf($strMIME_transformation_note,
  712.             '<a href="transformation_overview.php?'
  713.             . PMA_generate_common_url($db, $table) . '" target="_blank">',
  714.             '</a>');
  715.     echo '</p>';
  716. }
  717. ?>
  718. </div>
  719.  
  720. <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>
  721.